﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Daemon.Common.Generator
{
    public class CodeBuilder
    {
        public static (List<string> componentResult, List<string> variableResult) GenerateCode(List<Component> components)
        {
            var componentHtmlResult = new List<string>();
            var variableResult = new List<string>();
            components.ForEach(item =>
            {
                var generator = GeneratorCodeFactory.GetGenerator(item.Widget);
                var generatorResponse = generator.DoGenerate(item);
                componentHtmlResult.Add(generatorResponse.ComponentHtml);
                variableResult.AddRange(generatorResponse.VariableList);
            });

            return (componentHtmlResult, variableResult);
        }
    }
}
